package com.roc.util.constant;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

/**
 * 实名认证驳回理由
 * @author yzh
 *
 */
public enum AuthReason {
	ONE("1","图片不清晰（身份证/手持身份证过小/光线异常）"),
	TWO("2","代理审核申请驳回"),
	THREE("3","已回访核实信息"),
	FOUR("4","个人照片不能遮挡下巴/脸部/额头等面部信息"),
	FIRE("5","身份证正反面不能继续遮挡"),
	SIX("6","不支持电子照片，请现场拍摄"),
	SEVEN("7","个人照片需免冠/不配戴墨镜/平视并不闭眼拍摄"),
	EIGHT("8","个人照片与身份证照片差异过大"),
	NINE("9","手持照片非本人手持"),
	TEN("10","证件异常[无身份证正反、面/证件作假嫌疑/证件破损]"),
	ELEVEN("11","年龄限制，不予通过"),
	TWELVE("12","注册信息填写有误，请重新完善信息"),
	THIRTEEN("13","需关闭时间水印进行拍摄"),
	FOURTEEN("14","参考驳回记录照片信息"),
	FIFTEEN("15","其它，请查看实名范例"),
	SIXTEEN("16","身份证过期/即将过期，请办理新证件"),
	SEVENTEEN("17","手持身份证需露出完整手臂"),
	EIGHTEEN("18","需使用二代身份证进行认证"),
	NINETEEN("19","身份证有效日期输入错误");
	private String code;
	private String name;
	
	private AuthReason(String code,String name){
		this.code=code;
		this.name=name;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * 获取所有的枚举,以MAP返回
	 * @return
	 */
	public static List<HashMap<String,String>> getAllEnumMap() {
		
		List<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>();
		
		for (AuthReason mt : values()) {
			HashMap<String,String> map = new HashMap<String,String>();
			map.put("code", mt.getCode());
			map.put("name", mt.getName());
			list.add(map);
		}
		
		return list;
		
	}
	
	
	/**
	 * 通过ID获取中文名称
	 * @param code
	 * @return
	 */
	public static String getName(String code) {
		if (StringUtils.isBlank(code)) {
			throw new IllegalArgumentException("MerberFlag code " + code
					+ " is blank");
		}
		for (AuthReason tf : values()) {
			if (tf.getCode().equals(code)) {
				return tf.getName();
			}
		}
		throw new IllegalArgumentException("MerberFlag code  " + code
				+ " is not exist");
	}
	
	/**
	 * 通过值获取code
	 * @param name
	 * @return
	 */
   public static String valueOfCode(String name) {
		
		for (AuthReason au : values()) {
			if (au.getName().equals(name)) {
				return au.getCode();
			}
		}
		throw new IllegalArgumentException("MerchantStatus code " + name
				+ " is not exist");
	}


}
